var divStage, divCountDown, divCeleb, divCritical, divBrick,
	divLevel, divDifficulty, divScore, divHighScore, iTotalScore, iLevelScore,
	iCurMode, iCurLevel, audPlayback, celebAnim, iCurTimeAlive, iCelebCount, startTime,
	$MODE = {
		text: ["Phương My", "Thím Hà", "HKT"],
		max_level: [1, 1, 3]
	},
	$GAME = {def_mode: 0, max_mode: 2, def_level: 1},
	$COUNT_DOWN = {width: 120},
	$STAGE = {width: 0, height: 0, margin: 50},
	$CRITICAL = {top_dev: -50, left_dev: -40},
	$BRICK = {top: 0, left: 0, angle: 0, duration: 200, spin: -1080, beat_dev: 30, critical_beat: 5},
	$TIME_MILESTONE = {alive: 2000, max_game_time: 5000, level_dev: 100},
	$CELEB = {width: 60, height: 60, move_dev: 50,
		effect: [
			"rotate(-" + 15 + "deg)",
			"rotate(" + 15 + "deg)"
		]
	};

function CelebAnim(timeout) {
	var anim = [
		new Ext.Anim({
			from: {"-webkit-transform": $CELEB.effect[0]},
			to: {"-webkit-transform": $CELEB.effect[1]},
			duration: timeout/2
		}),
		new Ext.Anim({
			from: {"-webkit-transform": $CELEB.effect[1]},
			to: {"-webkit-transform": $CELEB.effect[0]},
			duration: timeout/2
		})
	];
	this.addEffect = function(top1, left1, top2, left2) {
		anim[0].config.from = {
			"-webkit-transform": $CELEB.effect[0],
			"top": top1,
			"left": left1
		};
		anim[0].config.to = {
			"-webkit-transform": $CELEB.effect[1],
			"top": top2,
			"left": left2
		}
		anim[1].config.from = {
			"-webkit-transform": $CELEB.effect[1],
			"top": top2,
			"left": left2
		};
		anim[1].config.to = {
			"-webkit-transform": $CELEB.effect[0],
			"top": top1,
			"left": left1
		}
	}
	this.getAnim = function() {
		return anim;
	}
}

function calculateScore(bCritical) {
	var criticalRatio = 1;
	(bCritical) ? criticalRatio = 2 : criticalRatio = 1;
	iLevelScore += (iCurMode*2 + iCurLevel)*criticalRatio;
}

function displayText() {
	divLevel.setHTML("Level: " + $MODE.text[iCurMode] + " " + iCurLevel);
	divScore.setHTML("Score: " + iLevelScore + " (" + iTotalScore + ")");
	divHighScore.setHTML("High score: " + iTotalScore);
}